package cn.qn.controller.upload;

import cn.qn.dto.ResponseDTO;
import cn.qn.moudle.image.Image;
import cn.qn.service.image.ImageService;
import com.alibaba.dubbo.config.annotation.Reference;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

@RestController
@Api("系统图片接口")
@RequestMapping("/system/image")
public class ImageController {

    @Reference(check = false)
    private ImageService imageApi;

    @ApiOperation(value = "新增图片", notes = "新增图片", produces = MediaType.APPLICATION_JSON_VALUE, response = Image.class)
    @RequestMapping(value = "/insert", method = RequestMethod.POST)
    public ResponseDTO insert(@RequestBody Image image) {
        Image image1 = imageApi.insert(image);
        return ResponseDTO.success(image1);
    }
    @ApiOperation(value = "通过图片ID获取图片", notes = "通过图片ID获取图片", produces = MediaType.APPLICATION_JSON_VALUE, response = Image.class)
    @RequestMapping(value = "/findById/{id}", method = RequestMethod.GET)
    public ResponseDTO findById(@PathVariable Integer id) {
        Image image = imageApi.findById(id);
        return ResponseDTO.success(image);
    }
}
